#include <stdio.h>
#include <string.h>
#include <unistd.h> //sleep

int main()
{
    #define NUM 100
    char bar[NUM+1]; //定义缓存区
    memset(bar, '\0' , sizeof bar);
    
    const char *lable = "|/-\\";//  \要转义一下
    int i=0;
    while(i<=100)
    {

        printf("\033[31m[%-100s][%3d%%] [%c] \r", bar,i, lable[i%4]); //%%单独显示%,从0开始直接mod就好
        fflush(stdout);
        bar[i]='#';
        i++;
       // sleep(1);
       usleep(50000);
    }


    printf("\n");
}
